/**
 * 模拟redis sdstrim方法
 */

def cset = "xy"
def s = "xxyyaxybxycyyxy"


def t1I = start = 0
def t2I = end = s.length() - 1
def t1 = s[t1I] as char
def t2 = s[t2I] as char

while(t1I <= end && cset.indexOf(s[t1I]) != -1) t1I++;
while(t2I > start && cset.indexOf(s[t2I] )!= -1) t2I--;

def len = t1I > t2I ? 0 : t2I - t1I + 1
println t1I
println len
println s.substring(t1I,t1I + len)

